using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
//using System.Data.SqlClient;
//using System.Data.SqlTypes;
//using System.Data.OleDb;
//using Evaluation3.data;
using Evaluation3.utils;
using Evaluation3.services;

public partial class regiter : System.Web.UI.Page
{

    usersServices objUser = new usersServices();

    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            Session["isFinish"] = false;
        }
        if ((bool)Session["isFinish"] == true) Response.Redirect("default.aspx");

    }
    protected void btn_selectDate_Click(object sender, EventArgs e)
    {
        //showHiddenCalendar.Visible = !showHiddenCalendar.Visible;
    }

    public bool checkMail()
    {
        objUser.HopThu = mem_mail.Text.Trim();

        return objUser.IsValidEmail();
    }

    #region formReset
    public void formReset()
    {
        mem_fullname.Text = null;
        mem_compName.Value = null;
        mem_compRes.Value = null;
        //mem_compYear.Text = null;
        mem_compWebsite.Text = null;
        mem_address.Value = null;
        mem_mail.Text = null;
        mem_phone.Text = null;
        mem_address.Value = null;

        emailNotify.Visible = false;

    } 
    
    protected void btn_Reset_Click(object sender, EventArgs e)
    {
        formReset();
    }
    #endregion

    #region btn_Save_Click()
    protected void btn_Save_Click(object sender, EventArgs e)
    {
         
        try
        {
            objUser.HovaTen = mem_fullname.Text.Trim();
            //objUser.TenTruyCap = txtTenTruyCap.Text.Trim();
            objUser.TenCongTy = mem_compName.Value.Trim();
            objUser.LinhVucKinhDoanh = mem_compRes.Value.Trim();
            objUser.NamThanhLap = Calendar1.Text;
            
            objUser.HopThu = mem_mail.Text.Trim();
            if (!objUser.IsValidEmail())
            {
                emailNotify.Visible = true;
                return;
            }

            objUser.DienThoai = mem_phone.Text.Trim();
            objUser.DiaChi = mem_address.Value.Trim();
            objUser.User_RegNew();
            
            formReset();
            
            UserForm.Visible = false;
            Session["isFinish"] = true;
            ThankMessage.Visible = true;
            Controls.Add(new LiteralControl("<META HTTP-EQUIV=\"REFRESH\" CONTENT=4>"));
        }
        catch (Exception ex)
        {

            throw ex;
        }
        // inserUserData((SqlConnection)Application.Get("myConn"), mem_fullname.Text, mem_sexSelect.SelectedValue, Calendar1.getDateTimeValue() , mem_address.Value, mem_mail.Text, mem_phone.Text);
    } 
    #endregion
}
